"use strict";
import express from 'express'
import fs from 'fs'						
import path  from 'path'
import bodyParser from 'body-parser'	
import ejs from 'ejs'
import Mock from 'mockjs'


const app = global.app= express();
////设置模板引擎
app.set('views', path.join(__dirname));
app.engine('.html',ejs.__express);
app.set('view engine', 'html');
//

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));		
app.use(express.static(path.join(__dirname)));



//首页
app.get('/',function(req,res,next){
	res.render('./index1')
})
app.get('/login',function(req,res,next){
	
	res.render('./app/page/login')
})
app.get('/home',function(req,res,next){
	res.render('./app/page/home')
})
//const TplPath = './app/page/';

//通知公告已收到
app.get('/notice/received',function(req,res,next){
	var data =Mock.mock({
	    // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
	    'data|1-10': [{
	        'id|+1': 1,
	        'sub':'@cparagraph(2)',
	        'time':'@datetime'
	        
	    }]
	})
	res.render('./app/page/notice/received',{
		data:data.data
	})
})
//通知公告已发送
app.get('/notice/send',function(req,res,next){
	res.render('./app/page/notice/send')
})
//通知公告已发送
app.get('/json',function(req,res,next){
	var json = JSON.parse(fs.readFileSync('./json.json').toString());
	res.json(json)
})
//通知公告已发送
app.get('/mock/people',function(req,res,next){
	var json = JSON.parse(fs.readFileSync('./mock/people.json').toString());
	res.json(json)
})



app.post('/app/trajectory/show_point',function(req,res,next){

	var mapData = [
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "1",
      "coordinatex": "117.345193",
      "coordinatey": "36.656476",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "1",
      "coordinatex": "117.345593",
      "coordinatey": "36.656476",
      "gmtCreateTime": "2017-11-08 15:12:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "王祥意",
      "remark": "",
      "superiorId": "0001",
      "userId": "5c76f836170b4998871eb4278091dc31"
    }
  ]
	res.json({
		"code": "C10000",
  		"message": "操作成功",
		"data":mapData
	})
})
app.post('/app/trajectory/show_one',function(req,res,next){
	var mapData2=[
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.145593",
      "coordinatey": "36.656476",
      "gmtCreateTime": "2017-11-08 15:14:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.145583",
      "coordinatey": "36.656496",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
 	{
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146583",
      "coordinatey": "36.656599",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },{
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146783",
      "coordinatey": "36.653599",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146683",
      "coordinatey": "36.653499",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.147683",
      "coordinatey": "36.653899",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
  ]
	
		var mapData3=[
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.145593",
      "coordinatey": "36.656576",
      "gmtCreateTime": "2017-11-08 15:14:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.145583",
      "coordinatey": "36.656496",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
 	{
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146583",
      "coordinatey": "36.656499",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },{
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146783",
      "coordinatey": "36.653599",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.146683",
      "coordinatey": "36.653499",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
    {
      "address": "山东省济南市历城区舜华南路2666号靠近济南市森林公安局",
      "communityId": "",
      "coordinatex": "117.247683",
      "coordinatey": "36.653899",
      "gmtCreateTime": "2017-11-08 15:17:31",
      "gmtUpdateTime": "",
      "id": "",
      "realName": "倪维超",
      "remark": "",
      "superiorId": "0001",
      "userId": "a675655f89c64d2883addc8ba6b5d231"
    },
  ]
		
	if(req.body.userId){
		res.json({
			"code": "C10000",
	  		"message": "操作成功",
			"data":mapData3
		})
		return ;
	}
	res.json({
		"code": "C10000",
  		"message": "操作成功",
		"data":mapData2
	})
	
})



module.exports = app;

